package com.example.design.proxy.dynamic;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @Description 动态代理代理类
 * @ClassName DynamicProxy
 * @Author Yumuhui
 * @Date 2020/5/14 1:01
 * @Version 1.0.0
 */
public class DynamicProxy implements InvocationHandler {

    private Object object;
    public DynamicProxy(Object object) {
        this.object = object;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("before");
        Object result = method.invoke(object, args);
        System.out.println("after");
        return result;
    }
}
